package com.xuyiwei.xblog.core.base.constant.enums;

import com.xuyiwei.xblog.core.base.constant.ConstantStatusInterface;

import java.util.HashMap;
import java.util.Map;

/**
 * 菜单是否打开的状态
 *
 * @author fengshuonan
 * @Date 2017年4月8日10:12:15
 */
public enum MenuOpenStatus implements ConstantStatusInterface<Integer,String> {
    NULL(null, ""),
    OPEN(1, "打开"),
    CLOSE(0, "关闭");

    private Integer key;
    private String desc;

    MenuOpenStatus(Integer key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    @Override
    public Integer getKey() {
        return key;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    static Map<Integer, MenuOpenStatus> map = new HashMap<>();

    static {
        for (MenuOpenStatus bst : MenuOpenStatus.values()) {
            map.put(bst.key, bst);
        }
    }

    public static MenuOpenStatus convert(Integer key) {
        MenuOpenStatus type = map.get(key);
        return (type != null) ? type : NULL;
    }


}
